package jmind.core.json;

import jmind.core.support.MethodSupport;

import com.alibaba.fastjson.serializer.BeanContext;

/**
 *         JSON.toJSONString(list, new ContextValueFilter(), SerializerFeature.DisableCircularReferenceDetect,
                SerializerFeature.WriteDateUseDateFormat);
 * @author xieweibo
 * @date 2016年9月18日
 */
public class ContextValueFilter implements com.alibaba.fastjson.serializer.ContextValueFilter {

    public Object process(BeanContext context, Object object, String name, Object value) {
        //    System.err.println(context + "--" + object + "---" + name + "---" + value);
        I18n annation = context.getAnnation(I18n.class);
        if (annation != null) {
            return MethodSupport.getProperty(object, annation.key()) + value;
        }
        return value;
    }

}
